from fastapi import WebSocket
from typing import Dict
import json
import logging

clients: Dict[str, WebSocket] = {}

async def send_message(client_id: str, message):
    # 发送消息给指定的客户端
    if client_id in clients:
        # logging.info(f"Message: {message} 发送给: {client_id}")
        # send_json = json.dumps({
        #     "emotion": message
        # })
        await clients[client_id].send_text(message)
        return {"status": "Message sent"}
    else:
        return {"status": "Client not connected"}
